import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { TSkill } from "../../../../../Message/Db/Tables/TSkill";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../../resource/ColorConfig";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { TSkillItem } from "../skill/TSkillItem";
import { QuickBuyWindow } from "../../common/QuickBuyWindow";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { EProp } from "../../../../../Message/Public/EProp";
type int = number;
//class PetSkillViewRenderer
    
    export  class PetSkillViewRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._tskill = arg1["skill"] as TSkill;
            this._isStudy = arg1["isStudy"] as Boolean;
            this._skillItem.skill = this._tskill;
            if (this._tskill) 
            {
                this._skillBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.PackItemBg);
                this._skillBg.width = 68;
                this._skillBg.height = 68;
                this._nameTxt.htmlText = HTMLUtil.addColor(this._tskill.skillName, ColorConfig.instance.getItemColorString(this._tskill.skillLevel + 1));
            }
            else 
            {
                this._skillBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.NotEnable);
                this._nameTxt.text = "";
            }
            if (this._isStudy) 
            {
                this._studyTxt.htmlText = Language.getString(54563);
                this._tipBg.height = 20;
                this._buyTxt.visible = false;
            }
            else 
            {
                this._studyTxt.htmlText = Language.getString(54564);
                this._tipBg.height = 40;
                this._buyTxt.visible = true;
                if (this._tskill) 
                {
                    this._buyTxt.visible = !this.isCanNotRefreshSkill(this._tskill.skillId);
                }
            }
            if (this._tskill == null) 
            {
                this._studyTxt.htmlText = Language.getString(54582);
            }
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 120, 140, this);
            this._nameTxt = ObjCreate.createTextField("", 0, 5, 120, 30, this, new GTextFormat(FontUtil.songtiName, 16, null, true));
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._skillBg = ObjCreate.createBg(28, 28, 68, 68, this, ImagesConst.PackItemBg);
            this._skillItem = new TSkillItem();
            this._skillItem.isDragAble = false;
            this._skillItem.width = 60;
            this._skillItem.height = 60;
            this._skillItem.move(32, 32);
            this.addChild(this._skillItem);
            this._tipBg = ObjCreate.createBg(10, 98, 100, 20, this, ImagesConst.SelectedBg);
            this._studyTxt = ObjCreate.createTextField("", 0, 100, 120, 20, this);
            this._studyTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._buyTxt = ObjCreate.createTextField("", 0, 120, 120, 20, this);
            this._buyTxt.htmlText = Language.getString(54565);
            this._buyTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            return;
        }

        /* internal  */onLinClickHandler(arg1: Object /* flash.events.Event */): void
        {
            QuickBuyWindow.instance.updateWindow(ECategory._ECategoryProp, EProp._EPropPetSkillRand);
            QuickBuyWindow.instance.updateDefaultAmount(1);
            QuickBuyWindow.instance.show();
            return;
        }

        /* internal  */isCanNotRefreshSkill(arg1: int): Boolean
        {
            var loc1=[5010603, 5010703, 5010803, 5014203];
            return !(loc1.indexOf(arg1) == -1);
        }

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_skillBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_skillItem: TSkillItem;

        /* internal */ /* var */_studyTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_buyTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_tipBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tskill: TSkill;

        /* internal */ /* var */_isStudy: Boolean;
    }
